package app.web.galgame.cgs.error;

import java.io.File;

import cn.lily.com.enviroment.Enviroment;

public class GalAutoError {
	
	private String analysePath = "H:/待处理/ANLYSE/Error";
	
	public void analyse() {
		
		File folder = new File(this.analysePath);
		
		File[] childFolders = folder.listFiles();
		for(File childFolder:childFolders){
			
			String name = childFolder.getName();
			String date = "20000101";
			for(File file:childFolder.listFiles()){
				
				String dateName = file.getName();
				if(dateName.endsWith(".date")){
					String tmpName = dateName.substring(0,6);
					
					if(tmpName.equals("000000")){
						date = "20000101";
					}else{
						
						if(tmpName.startsWith("9") || tmpName.startsWith("8")){
							date = "19" + tmpName;
						}else{
							date = "20" + tmpName;
						}
						
					}
					
					break;
				}
				
			}
			
			Enviroment.getEnv().getLogBean().beginLog();
			
			GalAutoErrorDetail detail = new GalAutoErrorDetail();
			detail.setFileName(name);
			detail.setFileDate(date);
			detail.setFolder(childFolder);
			
			detail.analyse();
			
			Enviroment.getEnv().getLogBean().endLog();
	
		}
		
	}
	
	public static void main(String[] args) {
		
		Enviroment.createEnv();		
		Enviroment.getEnv().getLogBean().beginLog();
		
		GalAutoError collect = new GalAutoError();
		collect.analyse();
		
		System.out.println("分析结束...........");
		
		Enviroment.getEnv().getLogBean().endLog();
		
	}
	
}
